package com.db4o.servlet.tools;
import java.io.*;

import javax.servlet.*;
import javax.servlet.http.*;

public abstract class AbstractServlet extends HttpServlet {

    private PrintWriter out;
    static final Object lock = new Object();

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        doPost(request, response);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

        synchronized (lock) {
        	
            out = response.getWriter();
            response.setContentType("text/html");

            println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
            println("<html>");
            println("<body>");

            respond(request, response);

            println("</body>");
            println("</html>");
        }
    }

    public void println(String msg) {
        out.println(msg);
    }

    public abstract void respond(HttpServletRequest request, HttpServletResponse response);

}
